import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Layouts from 'vite-plugin-vue-layouts'
import VueRouter from 'unplugin-vue-router/vite'
// https://vitejs.dev/config/

export default defineConfig({
  plugins: [
    VueRouter({
      routesFolder: [
        {
          src: "src/pages",
        },
        {
          src: "src/modules/",
          filePatterns: '**/views/**/*',

        },
      ], // 自动扫描 src/pages 目录

      dts: 'src/typed-router.d.ts', // 自动生成类型声明文件
    }),
    vue(),
    vueJsx(),
    Layouts(),
  ],
  server: {
    proxy: {

      '/api': {
        target: 'http://192.168.1.120:16001',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@m': fileURLToPath(new URL('./src/modules', import.meta.url))
    }
  }
})
